/**
 * @file usr_mos_dri_boost.h
 * @author 黑马小乌龟 (532352406@qq.com)
 * @brief 
 * @version 0.1
 * @date 2025-07-16
 * 
 * @copyright Copyright (c) 2025
 * 
 */
#ifndef USR_MOS_DRI_BOOST__H_H
#define USR_MOS_DRI_BOOST__H_H

#ifdef __cplusplus
extern "C"{
#endif
#include<stdint.h>
#include<stdio.h>

#include "hc32_ll.h"
#include "ev_hc32f334_lqfp64_bsp.h"

/* Function of this example. */
#define APP_FUNC_NORMAL_SINGLE_PWM          (0U)
#define APP_FUNC_SINGLE_EDGE_ALIGNED_PWM    (1U)
#define APP_FUNC_TWO_EDGE_SYMMETRIC_PWM     (2U)

/* Specify the function of the example. */
#define APP_FUNC                            (APP_FUNC_NORMAL_SINGLE_PWM)


#define TMRA_UNIT                       (CM_TMRA_4)
#define TMRA_PERIPH_CLK                 (FCG2_PERIPH_TMRA_4)
#define TMRA_PWM_CH                     (TMRA_CH1)

#define TMRA_PWM_PORT                   (GPIO_PORT_B)
#define TMRA_PWM_PIN                    (GPIO_PIN_03)
#define TMRA_PWM_PIN_FUNC               (GPIO_FUNC_17)

#define TMRA_MD                         (TMRA_MD_SAWTOOTH)
#define TMRA_DIR                        (TMRA_DIR_UP)
// #define TMRA_PERIOD_VAL                 (8U - 1U)
// #define TMRA_PWM_CMP_VAL                (4U - 1U)
// #define TMRA_PERIOD_VAL                 (746U - 1U)  /*50uS*/
#define TMRA_PERIOD_VAL                     (373U - 1U)  /*25uS*/
// #define TMRA_PWM_CMP_VAL                (8U - 1U)

#define TMRA_INT_TYPE                   (TMRA_INT_OVF)
#define TMRA_INT_FLAG                   (TMRA_FLAG_OVF)

#define TMRA_INT_PRIO                   (DDL_IRQ_PRIO_03)
#define TMRA_INT_IRQn                   (TMRA_4_OVF_UDF_IRQn)
#define TMRA_OVF_UDF_IRQ_HANDLER        TMRA_4_Ovf_Udf_Handler


void pid_process_period_timer_init(void);
uint8_t get_pid_period_flg(void);


#ifdef __cplusplus
}
#endif

#endif //USR_MOS_DRI_BOOST__H_H


